import request from "@/utils/request";

type getIndexType = {
  data: indexDate
  noticeList: any
}


type indexDate = {
  bigPromotionModule: floorList[]
  categoryHotSellModule: category
  focusList: focus[]
  indexActivityModule: indexActivity[]
  kingKongModule: kingKong[]
  policyDescList: policy[]
  sceneLightShoppingGuideModule: styleItem[]
  tagList: tag[]
}

// -------------------------------------------------
type floorList = {
  cells: any   //里面套数组。没有写
  columnNum: number
  floorType: number
  height: number
  layout: number
  style: number
  taskId: number
}
// ---------------------------------------------------

export type category = {
  categoryList: cate[]
  title: string
  titleTargetUrl: string
}

export type cate = {
  categoryName: string
  extra: any
  itemPicBeanList: item[]
  picUrl: string
  showPicUrl: string
  targetUrl: string
}
interface item {
  itemId: number
  picUrl: string
}
// -----------------------------------------

export type focus = {
  expireTime: number
  extra: any
  id: number
  name: string
  onlineTime: number
  originSchemeUrl: string
  picUrl: string
  targetUrl: string
}

// -------------------------------------------

export interface indexActivity {
  activityPrice: string
  backgroundUrl: string
  originPrice: string
  picUrl: string
  showPicUrl: string
  subTitle: string
  tag: string
  targetUrl: string
  title: string
}
// ---------------------------------------------
export type kingKong = {
  background: string
  kingKongList: kingList[]

}
export interface kingList {
  picUrl: string
  schemeUrl: string
  text: string
  textColor: string
}

// -------------------------------------------

export interface policy {
  desc: string
  icon: string
  schemeUrl: string
}

// -----------------------------------

interface tag {
  appListPicUrl: string
  floorPrice: number
  id: number
  name: string
  newOnShelf: boolean
  picUrl: string
  simpleDesc: string
  webIndexVerticalPicUrl: string
}

// ------------------------------------------
// export interface styleBanner {
//   desc: string
//   descColor: string
//   extra: any
//   originSchemeUrl: string
//   picUrl: string
//   targetUrl: string
//   title: string
//   titleColor: string
// }
export type styleItem = {
  desc: string
  descColor: string
  extra: any
  itemFrom: number
  itemPicBeanList: itemPicBean[]
  originSchemeUrl: string
  picUrlList: string[]
  targetUrl: string
  title: string
  titleColor: string


}
interface itemPicBean {
  itemId: number
  picUrl: string

}



// -------------------------------------------------------------------------------

export type currentCategory = {
  categoryItemList?: categoryItem[]
  categoryList?: categorys[]
  currentCategory: currentCate
}

type currentCate = {
  bannerList: banner[]
  bannerUrl: string
  categoryType: number
  extra: null
  frontDesc: string
  frontName: string
  frontNameIcon: null
  iconUrl: string
  id: number
  imgUrl: null
  level: string
  name: string
  showIndex: number
  subCateList: any
  superCategoryId: number
  type: number
  wapBannerUrl: string
  wapExpandPicTargetUrl: null
}

export interface banner {
  // extra:any
  // id:number
  picUrl: string
  targetUrl: string

}

export type categoryItem = {
  category: categ
  itemIdList: any
  itemList: items[]
}

export interface categ {
  bannerList: null
  bannerUrl: null
  categoryType: number
  extra: null
  frontDesc: string
  frontName: string
  frontNameIcon: null
  iconUrl: null
  id: number
  imgUrl: null
  level: string
  name: string
  showIndex: number
  subCateList: any
  superCategoryId: number
  type: number
  wapBannerUrl: string
  wapExpandPicTargetUrl: null
}

export interface items {
  listPicUrl: string
  name: string
  pieceUnitDesc: string
  primaryPicUrl: string
  primarySkuId: number
  scenePicUrl: string
  simpleDesc: string
  sortOriginPrice: number
  zoomTransPicV2Url: string
  colorNum: number
  counterPrice: number

}


export interface categorys {
  bannerList: null
  bannerUrl: string
  categoryType: number
  extra: null
  frontDesc: string
  frontName: string
  frontNameIcon: null
  iconUrl: string
  id: number
  imgUrl: string
  level: string
  name: string
  showIndex: number
  subCateList: any
  superCategoryId: number
  type: number
  wapBannerUrl: string
  wapExpandPicTargetUrl: null
}

export default {
  getIndex() {
    return request.get<any, getIndexType>('/xhr/index.json?__timestamp=1662542610854&')
  },
  getChannel(id: number) {
    return request.get<any, currentCategory>(`/item/list.json?__timestamp=1630136511866&categoryId=${id}`)
  }
}


